<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:rich="http://richfaces.org/rich">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">

            <div class="tituloPagina">
                <h:graphicImage value="/LaCruz_v2/faces/javax.faces.resource/img/report-icon.png" />
                <h:outputText value="#{bundle.CreateUsuarioAdmTitle}" style="padding-left: 10px" ></h:outputText>
            </div>

        </ui:define>
        <ui:define name="body">

            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form id="formCadUsuario" prependId="false">
                <h:outputScript name="js/jquery.maskedinput-1.2.1.js" target="head" rendered="true"/>
                <h:outputScript name="js/jquery-validate/jquery.validate.js" target="head" rendered="true" />


                <table style="width:100%;    padding-top: 10px;" cellspacing="4">

                    <tr>
                        <td align="center">
                            <table style="text-align: left" class="tableCadastro" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td class="tdTitulo">
                                            <h:outputLabel value="#{bundle.CreateUsuarioDadosUsuarioTitulo}"/>
                                        </td>

                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <table class="tableCadastroUsuarioInterna" cellspacing="3">

                                                <tr>
                                                    <td style="width:104px">
                                                        <h:outputLabel value="#{bundle.CreateUsuarioLabel_nome}" for="nome" />
                                                    </td>
                                                    <td colspan="2" >
                                                        <h:inputText id="nome" value="#{usuarioController.selected.nome}" size="40" maxlength="50" title="#{bundle.CreateUsuarioTitle_nome}" required="true" requiredMessage="#{bundle.CreateUsuarioRequiredMessage_nome}"/>
                                                    </td>

                                                </tr>
                                                <tr>
                                                    <td>
                                                        <h:outputLabel value="#{bundle.CreateUsuarioAdmLabel_cargo}" for="cargo" />
                                                    </td>
                                                    <td>
                                                        <h:inputText id="cargo" value="#{usuarioAdmController.selected.cargo}" maxlength="40" title="#{bundle.CreateUsuarioAdmTitle_cargo}" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" style="border-top-style: dashed; border-top-width: 1px;">
                                            <table class="tableCadastroUsuarioInterna" cellspacing="5">
                                                <tr>
                                                    <td style="width:100px">
                                                        <h:outputLabel value="#{bundle.CreateUsuarioLabel_email}" for="email" />
                                                    </td>
                                                    <td>
                                                        <h:inputText id="email" value="#{usuarioController.selected.email}" maxlength="50" title="#{bundle.CreateUsuarioTitle_email}" required="true" requiredMessage="#{bundle.CreateUsuarioRequiredMessage_email}"/>
                                                    </td>
                                                </tr>

                                                <tr>
                                                    <td>
                                                        <h:outputLabel value="#{bundle.CreateUsuarioLabel_senha}" for="senha" />
                                                    </td>
                                                    <td>
                                                        <h:inputSecret id="senha" value="#{usuarioController.selected.senha}" maxlength="8" title="#{bundle.CreateUsuarioTitle_senha}" required="true" requiredMessage="#{bundle.CreateUsuarioRequiredMessage_senha}"/>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <h:outputLabel value="#{bundle.CreateUsuarioLabel_confirmarsenha}" for="confirmarsenha"/>
                                                    </td>
                                                    <td>
                                                        <h:inputSecret id="confirmarsenha" maxlength="8"/>
                                                    </td>
                                                </tr>

                                            </table>
                                        </td>
                                    </tr>

                                </tbody>
                            </table>

                        </td>
                    </tr>
                    
                    <tr>
                        <td colspan="3" align="right">
                            <div class="buttonStyle">

                                <h:commandLink value="#{bundle.CreateUsuarioAdmSaveLink}" action="#{usuarioAdmController.create}">
                                </h:commandLink>

                            </div>

                        </td>
                    </tr>
                </table>
               
                <script type="text/javascript">

        //Validaçao de formulário
        $(document).ready(function(){
            //id do form
            jQuery('#formCadUsuario').validate( {

                rules: {
                    numero: {
                        number: true
                    },
                    cep: {
                        number: true
                    },
                    cpf: {
                        number: true
                    },
                    confirmarsenha: {
                        equalTo:"#senha"
                    },
                    senha:{
                        minlength:8

                    },
                    email:{
                        email:true
                    }
                   },
                //mensagens, caso não bater com as regras
                messages: {

                    numero: {
                        number: "valor deve ser num&eacute;rico"
                    },
                    cep: {
                        number: "valor deve ser num&eacute;rico"
                    },
                     cpf: {
                        number: "valor deve ser num&eacute;rico"
                    },
                    confirmarsenha: {
                        equalTo:"deve ser igual ao campo 'Senha'"
                    },
                    senha:{
                        minlength:"sua senha deve ter 8 caracteres"
                    },
                    email:{
                        email:"e-mail inv&aacute;lido"
                    }
                }
            });
        });

                </script>


            </h:form>
        </ui:define>
    </ui:composition>

</html>
